<article id="wikiArticle">
<div></div>
<p><code><strong>includes()</strong></code>方法判断类型化数组中是否含有特定元素，并相应返回<code>true</code> 或者<code>false</code> ，这个方法的算法和<a href="Reference/Global_Objects/Array/includes" title="includes() 方法用来判断一个数组是否包含一个指定的值，根据情况，如果包含则返回 true，否则返回false。"><code>Array.prototype.includes()</code></a><em>相同。</em> <em>TypedArray</em> 是这里的 <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray#TypedArray_objects">类型化数组</a> 之一。</p>
<h2 id="语法">语法</h2>
<pre><code class="language-javascript"><var>typedarray</var>.includes(<var>searchElement</var>[, <var>fromIndex</var>]);</code></pre>
<h3 id="参数">参数</h3>
<dl>
<dt><code>searchElement</code></dt>
<dd>要搜索的元素。</dd>
<dt><code>fromIndex</code></dt>
<dd>可选，数组中的位置，在这里开始搜索 <code>searchElement</code>；默认为 0。</dd>
</dl>
<h3 id="返回值">返回值</h3>
<p><a href="Reference/Boolean" title="此页面仍未被本地化, 期待您的翻译!"><code>Boolean</code></a>。</p>
<h2 id="示例">示例</h2>
<pre><code  class="language-javascript">var uint8 = new Uint8Array([1,2,3]);
uint8.includes(2);     // true
uint8.includes(4);     // false
uint8.includes(3, 3);  // false

// NaN 的处理 （仅仅对 Float32 和 Float64 为 true）
new Uint8Array([NaN]).includes(NaN); // false, 因为 NaN 传递给构造器时转换为 0
new Float32Array([NaN]).includes(NaN); // true;
new Float64Array([NaN]).includes(NaN); // true;
</code></pre>
<h2 id="规范">规范</h2>
<table class="standard-table">
<tbody>
<tr>
<th scope="col">Specification</th>
<th scope="col">Status</th>
<th scope="col">Comment</th>
</tr>
<tr>
<td><a class="external" href="https://www.ecma-international.org/ecma-262/7.0/#sec-%typedarray%.prototype.includes" hreflang="en" lang="en" rel="noopener">ECMAScript 2016 (ECMA-262)<br/><small lang="zh-CN">TypedArray.prototype.includes</small></a></td>
<td><span class="spec-Standard">Standard</span></td>
<td>初始定义。</td>
</tr>
<tr>
<td><a class="external" href="https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.includes" hreflang="en" lang="en" rel="noopener">ECMAScript Latest Draft (ECMA-262)<br/><small lang="zh-CN">TypedArray.prototype.includes</small></a></td>
<td><span class="spec-Draft">Draft</span></td>
<td> </td>
</tr>
</tbody>
</table>
<h2 id="浏览器兼容性">浏览器兼容性</h2>
<div><div class="blockIndicator warning"><strong><a class="external" href="https://github.com/mdn/browser-compat-data" rel="noopener">We're converting our compatibility data into a machine-readable JSON format</a></strong>.
            This compatibility table still uses the old format,
            because we haven't yet converted the data it contains.
            <strong><a class="new" href="/zh-CN/docs/MDN/Contribute/Structures/Compatibility_tables" rel="nofollow">Find out how you can help!</a></strong></div>
<div class="htab">
<a id="AutoCompatibilityTable" name="AutoCompatibilityTable"></a>
<ul>
<li class="selected"><a>Desktop</a></li>
<li><a>Mobile</a></li>
</ul>
</div></div>
<div id="compat-desktop">
<table class="compat-table">
<tbody>
<tr>
<th>Feature</th>
<th>Chrome</th>
<th>Firefox (Gecko)</th>
<th>Edge</th>
<th>Internet Explorer</th>
<th>Opera</th>
<th>Safari</th>
</tr>
<tr>
<td>Basic support</td>
<td>47</td>
<td>43</td>
<td>14</td>
<td><span style="color: #f00;">未实现</span></td>
<td>34</td>
<td>10</td>
</tr>
</tbody>
</table>
</div>
<div id="compat-mobile">
<table class="compat-table">
<tbody>
<tr>
<th>Feature</th>
<th>Android</th>
<th>Chrome for Android</th>
<th>Firefox Mobile (Gecko)</th>
<th>IE Mobile</th>
<th>Opera Mobile</th>
<th>Safari Mobile</th>
</tr>
<tr>
<td>Basic support</td>
<td><span style="color: #f00;">未实现</span></td>
<td>47</td>
<td>43</td>
<td><span style="color: #f00;">未实现</span></td>
<td>34</td>
<td>10</td>
</tr>
</tbody>
</table>
</div>
<h2 id="另见">另见</h2>
<ul>
<li><a href="Reference/Global_Objects/Array/includes" title="includes() 方法用来判断一个数组是否包含一个指定的值，根据情况，如果包含则返回 true，否则返回false。"><code>Array.prototype.includes()</code></a></li>
<li><a href="Reference/Global_Objects/String/includes" title="includes() 方法用于判断一个字符串是否包含在另一个字符串中，根据情况返回 true 或 false。"><code>String.prototype.includes()</code></a></li>
<li><a href="Reference/Global_Objects/TypedArray/indexOf" title="indexOf() 方法返回在类型数组中可以找到给定元素的第一个索引，如果不存在，则返回-1。 方法具有与 Array.prototype.indexOf() 相同的算法。 TypedArray是这里的类型化数组类型之一。"><code>TypedArray.prototype.indexOf()</code></a></li>
</ul>
</article>